package com.baymax.springboot.cli.controller;

import com.baymax.springboot.cli.services.ITransactionalSrv;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 *
 */
@Controller
@RequestMapping("/transaction")
public class TransactionalTestController {


    @Autowired
    private ITransactionalSrv transactionalSrv;

    /**
     *
     * @return
     */
    @GetMapping("/doTransaction")
    public String doTransaction(Model model) {
        transactionalSrv.doTran();
        return "transaction";
    }

    @GetMapping("/doTransactionFail")
    public String doTransactionFail(Model model) {
        transactionalSrv.doTranFail();
        return "transaction";
    }

    @GetMapping("/noTransactionFail")
    public String noTransactionFail(Model model) {
        transactionalSrv.noTranFail();
        return "transaction";
    }
}
